﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SaunaClient.Model.Logger
{
    /// <summary>
    /// Composite Logger class that outputs log messages of all loggers
    /// </summary>
    /// <remarks>
    /// This class is thread safe. 
    /// </remarks>
    /// <dates>
    /// 15/05/2011 - created by Chiaki Sato
    /// </dates>
    class CompositeLogger : ILogger
    {
        private ArrayList arrayLoggers = new ArrayList();

        public void add(ILogger logger)
        {
            arrayLoggers.Add(logger);
        }

        public string Write(string message)
        {
            string logMessage =""; 

            foreach (ILogger logger in arrayLoggers)
            {
                logMessage = logger.Write(message);
            }

            // return the last logger message only for the unit test purpose
            return (logMessage);            
        }
    }
}